package com.szzg10.webservice.chapter1;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

public class TeamsUtility {

	private Map<String, Team> team_map;

	public TeamsUtility() {
		team_map = new HashMap<String, Team>();
	}
	
	public Team getTeam(String name) {
		return team_map.get(name);
	}
	
	public List<Team> getTeams() {
		
		List<Team> teams = new ArrayList<Team>();
		
		Set<String> keySet = team_map.keySet();
		for(String element: keySet) {
			teams.add(team_map.get(element));
		}
		
		return teams;
	}
	
	public void make_test_teams() {
		
		List<Player> players1 = new ArrayList<Player>();
		players1.add(new Player("Peter"));
		players1.add(new Player("Anne"));
		Team team1 = new Team("team1",players1);
		
		List<Player> players2 = new ArrayList<Player>();
		players2.add(new Player("Sue"));
		players2.add(new Player("Ken"));
		Team team2 = new Team("team2",players2);
		
		List<Player> players3 = new ArrayList<Player>();
		players3.add(new Player("Tim"));
		players3.add(new Player("Denis"));
		Team team3 = new Team("team3",players3);
		
		team_map.put("team1", team1);
		team_map.put("team2", team2);
		team_map.put("team3", team3);
	}
	
}
